#ifndef CAMERA_CONFIG_H
#define CAMERA_CONFIG_H

#include <QVector>
#include <QStringList>
#include <QSize>
#include <QJsonArray>
#include <QMap>

namespace Camera {


struct Config {
	QVector<QSize> resolution;
	QVector<int> bitwidth;
	QStringList color;
	QVector<int> analog;
	QVector<int> digital;
	QStringList exposure;
};

struct Command {
	QMap<QString, QMap<QString, int>> resolution;
	QMap<int, uchar> bitwidth;
	QMap<int, uchar> analog;
	QVector<QPair<uchar, uchar>> analogAddress;
	QVector<uchar> analogExtraCode;
	// digital
	QMap<QString, QMap<int, int>> exposure;
	QPair<uchar, uchar> exposureAddress;
	QSize maxSize;
	int queueSize;
};



class Parser
{
public:
	static Config readConfig(QString filename);
	static Command readCommand(QString filename);

private:
	static const QString Root;
	static const QString Resolution;
	static const QString Size;
	static const QString Width;
	static const QString Height;
	static const QString Bitwdith;
	static const QString Color;
	static const QString Analog;
	static const QString Digital;
	static const QString Exposure;

	static const QVector<QString> resolutions;

	static QVector<QSize> getResolution(const QJsonArray& array);
	static QVector<int> getBitwidth(const QJsonArray& array);
	static QStringList getColor(const QJsonArray& array);
	static QVector<int> getAnalog(const QJsonArray& array);
	static QVector<int> getDigital(const QJsonArray& array);
	static QStringList getExposure(const QJsonArray& array);
};

}


#endif

